import 'package:get/get.dart';
import 'package:flutter/material.dart';

class Search extends StatelessWidget {
  final List<Color> rankColors = [
    Colors.amber, // 🥇 金
    Colors.grey, // 🥈 银
    Colors.brown, // 🥉 铜
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            // 标题
            Container(
              margin: EdgeInsets.fromLTRB(20, 40, 20, 10),
              child: Text(
                "排行榜",
                style: TextStyle(
                  fontSize: 26,
                  fontWeight: FontWeight.bold,
                  // color: Colors.pinkAccent,
                ),
              ),
            ),

            // 分割线
            Divider(
              color: Colors.white30,
              thickness: 1,
              indent: 20,
              endIndent: 20,
            ),

            // 列表
            ListView.builder(
              physics: NeverScrollableScrollPhysics(),
              shrinkWrap: true,
              itemCount: 9,
              itemBuilder: (context, index) {
                return Container(
                  margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
                  child: Card(
                    // color: Colors.grey[900], // 深灰色卡片
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(12),
                    ),
                    elevation: 2, // 小阴影
                    child: ListTile(
                      contentPadding: EdgeInsets.symmetric(
                        horizontal: 16,
                        vertical: 10,
                      ), // 内间距更舒服
                      leading: ClipRRect(
                        borderRadius: BorderRadius.circular(8),
                        child: Image.asset(
                          "assests/${index + 1}.webp",
                          width: 50,
                          height: 50,
                          fit: BoxFit.cover,
                        ),
                      ),
                      title: Text(
                        "选手 ${index + 1}",
                        style: TextStyle(fontWeight: FontWeight.bold),
                      ),
                      subtitle: Text("欢迎观看", style: TextStyle(fontSize: 12)),
                      trailing: Text(
                        "${index + 1}",
                        style: TextStyle(
                          color: index < 3 ? rankColors[index] : Colors.grey,
                          fontSize: 18,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                      onTap: () {
                        Get.snackbar("点击了", "第 ${index + 1} 项");
                      },
                    ),
                  ),
                );
              },
            ),
          ],
        ),
      ),
    );
  }
}
